package com.itheima.health.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.health.pojo.OrderSetting;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @program: health_paret
 * @description:
 * @author: Mr.Wang
 * @creadte: 2020-11-09 13:16
 **/
public interface OrderSettingMapper extends BaseMapper<OrderSetting> {
    @Select("select ORDERDATE,NUMBER,RESERVATIONS from t_ordersetting where ORDERDATE BETWEEN #{beginDate} and #{endDate}")
    List<OrderSetting> selectCurrentMonth(@Param("beginDate") String beginDate, @Param("endDate") String endDate);

    @Update("update t_ordersetting SET NUMBER=#{number} WHERE ORDERDATE=#{settingDay}")
    Boolean updateNumberInfoOrderSetting(@Param("number") int number, @Param("settingDay") String settingDay);

    @Select("select count(1) from t_ordersetting where number >RESERVATIONS and ORDERDATE=#{date} ")
    int findNumberThenReservations(@Param("date") String date);

    @Update("update t_ordersetting set RESERVATIONS=RESERVATIONS+1 where ORDERDATE= #{orderDate}")
    void updateReservationByOrderDate(String orderDate);
}
